# -*- coding: utf-8 -*-

"""
DateTime   : 2020/12/23 18:40
Author     : ZhangYafei
Description: 
"""
import os

"""
# 1.获取当前运行的py脚本所在路径
abs = os.path.abspath(__file__)
print(abs) # G:\学习\Python学习\Python基础\code\chapter20\路径相关.py
path = os.path.dirname(abs)
print(path) # G:\学习\Python学习\Python基础\code\chapter20
# """
base_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(base_dir, 'files', 'info.txt')
print(file_path)
if os.path.exists(file_path):
    file_object = open(file_path, mode='r', encoding='utf-8')
    data = file_object.read()
    file_object.close()

    print(data)
else:
    print('文件路径不存在')
